<?php
namespace Mob\Model;

use Think\Model;
use Think\Hook;

/**数据字典模型
 * Class InfoModel
 */


class UploadFileModel extends Model
{
   protected $tableName = 'uploadFile';

   public function load($maxSize=3145728,$exts=array('jpg', 'gif', 'png', 'jpeg'),$rootPath='./Uploads/')
   {
   	 $upload = new \Think\Upload();// 实例化上传类
    $upload->maxSize   =     $maxSize ;// 设置附件上传大小
    $upload->exts      =     $exts;// 设置附件上传类型
    $upload->rootPath  =     $rootPath; // 设置附件上传根目录
    $upload->savePath  =     ''; // 设置附件上传（子）目录
    // 上传文件
    $info   =   $upload->upload()['photo'];
    if($info)
    {
    $data['Flg'] =1;
    }else
    {
    $data['Flg'] =0;
    }
    print_r($info);
    $data['serialno']=time();
    $data['uploadTime']=time();
    $data['uploadUid']=get_uid();
    $data['srcFileName']=$info['name'];
    $data['fileType']=$info['type'];
    $data['filesize']=$info['size'];
    $data['ext']=$info['ext'];
    $data['md5']=$info['md5'];
    $data['sha1']=$info['sha1'];
    $data['fileName']=$info['savename'];
    $data['savepath']=$info['savepath'];
    $data['rootPath']=$info['rootPath'];
    $data['fullPath']=$info['rootPath'].$info['savepath'].$info['savename'];
    $res = $this->add($data);
    if($res)
    {
   $array = array('Flg'=>$data['Flg'],'serialno'=>$data['serialno'],'fullPath'=>$data['fullPath']);

    }else
    {
    $array = array('Flg'=>$data['Flg']);
    }
   return $array;
   }

   public function get_FilePath($serialno)
   {
   	return $this->where(array('serialno'=>$serialno,'Flg'=>1))->getField('fullPath');

   }










}